package com.lsl.test1;

/**
 * @author lishuailong
 * @create 2020-06-09 17:14
 */
public class 模板设计模式 {
    public static void main(String[] args) {
        TakeFoodFromTheFridge theFridge = new TakeFoodFromTheFridge() {
            @Override
            public void take() {
                System.out.println("拿苹果@");
            }
        };
        theFridge.takeFood();
    }
}


abstract class TakeFoodFromTheFridge{

    private void openFridge(){
        System.out.println("打开冰箱！");
    }

    public abstract void take();

    private void closeFridge(){
        System.out.println("关闭冰箱！");
    }

    public void takeFood(){
        this.openFridge();
        this.take();
        this.closeFridge();
    }

}


